<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
  <title>代码生成</title>
  <meta name="description" content="" />
  <meta name="author" content="pc" />
  <meta name="viewport" content="width=device-width,initial-scale=1.0, maximum-scale=1, minimum-scale=1, user-scalable=no" />
  <meta name="screen-orientation"content="portrait">
  <meta name="format-detection" content="telephone=no" />
  <#include "/inc/common.html">
</head>
<body>
		    <table  id="solrDg" 
				    data-toggle="table"  
				    data-method="post" 
				    data-content-type="application/json"
				    data-url="${request.contextPath}/sysCode/selectPage"
				    data-toolbar="#solrTb"
				    data-height="300"
					data-show-header="true" 
					data-cache="false"
					data-click-to-select="true"  
					data-single-select="false" 
					data-striped="true"
					data-search="false" 
					data-pagination="true"
					data-side-pagination="server"
					data-query-params-type="''"
					data-page-size="5"
					data-page-number="1"
					data-page-list="[5,10,20,50,100,500,1000]"
					data-query-params="solrQueryParams"
					data-pagination-loop="false"
					data-classes="table table-hover table-condensed"
			        data-sort-stable="true"
			        data-show-footer="false"
			        data-resizable="true"
			        data-reorderable-columns="true"
					data-show-toggle="true"
			        data-show-columns="true"
					data-show-multi-sort="true"
					data-show-pagination-switch="true"
					data-show-export="true"
					data-export-types="['excel']"
					data-export-options='{
				         "fileName": "solr列表", 
				         "worksheetName": "sheet"
				    }'
			>
			<thead>
				<tr>
                      <th data-field="state"  data-align="center"  data-checkbox="true"></th>
                      <th data-field="index" data-title="序号" data-align="center"  data-formatter="getRowIndex"></th>
                      <th data-field='tableName' data-sortable='true' data-align='center'  data-title='表名'></th>
                      <th data-field='engine' data-sortable='true' data-align='center'  data-title='引擎'></th>
                      <th data-field='tableComment' data-sortable='true' data-align='center'  data-title='备注'></th>
                      <th data-field='createTime' data-sortable='true' data-align='center'  data-title='创建时间'></th>
				</tr>
			</thead>
		</table>
		
        <div id="solrTb"  style="padding: 5px; height: auto">
			<div>
			   <form id="solrQueryForm" method="post" action="">
                           <table align="left">
                              <tr>
                                      <td>表名:<input id='tableName' name='tableName'  style="width: 120px;height:30px;"/></td>
                                      <td><input type="button" value="生成" style="width: 80px; height: 30px; vertical-align: bottom; line-height: 10px;" class="btn-primary" onclick="code()" /></td>
								      <td><input type="button" value="返回" style="width: 80px; height: 30px; vertical-align: bottom; line-height: 10px;" class="btn-primary" onclick="back()" /></td>
                             </tr>
                           </table>         
			   </form>

			</div>
		</div>
		<script type="text/javascript">
	   function solrQueryParams(params){
			params.tableName=$('#tableName').val();
			return params;
	    }
	    //显示行号
		function getRowIndex(value, row, index) {  
		   var page=$("#solrDg").bootstrapTable("getOptions");
		   return page.pageSize*(page.pageNumber-1)+index+1;
		}  
	    //生成代码
        function code(){
	      var row = $('#solrDg').bootstrapTable('getSelections');
		  if (row.length>0){
			   var names="";
			   for (i = 0; i < row.length; i++) {
			   	    if(i==row.length-1){
						names+=row[i].tableName;
					}else{
						names+=row[i].tableName+",";
					}
			   }
			   location.href = "${request.contextPath}/sysCode/code?tables="+names ;
	        }else{
	        	   layer.open({
					  title: '提示信息'
					  ,content: '请选择需要生成的行!',
					  btnAlign: 'c'
					}); 
	        }
	    }
	    //查询
		function findSolr(){
			$("#solrDg").bootstrapTable("refresh",{
					"silent":true,
					"resetOffset":false,
					"url":"${request.contextPath}/solr/selectPage",
					query:$('#solrQueryForm').serializeObject()
			}); 
		} 
	    //清空查询条件
	   function clearSolr(){
	       $(':input','#solrQueryForm') 
		    .not(':button, :submit, :reset, :hidden') 
		    .val('') 
		    .removeAttr('checked') 
		    .removeAttr('selected'); 
	   }
	   function back(){
		   location.href = "${request.contextPath}/sysCode/init";
	   }
	</script>
 </body>
</html>